<extend name="Public/base"/>
<block name="body">
    <div class="main-title">
        <h2>{$info['id']?'编辑':'新增'}后台菜单</h2>
    </div>
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <form action="{:U('save')}" method="post" class="form-horizontal">
        <div class="form-item">
            <label class="item-label">分类名称<span class="check-tips">（用于显示）</span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="systematicname" value="{$info.title|default=''}">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">上级菜单<span class="check-tips">（支持无限级）</span></label>
            <div class="controls">
                <select name="pid">
                    <volist name="data" id="data">
                        <option value="{$data.id}">{$data.title_show}{$data.systematicname}</option>
                    </volist>
                </select>
            </div>
        </div>

            <div class="form-item">
                <label class="item-label">分类展示图片</label>
                <div class="controls">
                    <input type="file" id="upload_picture_pic">
                    <input type="hidden" name="pic" id="cover_id_pic"/>
                    <input type="hidden" name="pic_path" id="cover_id_path"/>
                    <div class="upload-img-box"></div>
                </div>
                <script type="text/javascript">
                    //上传图片
                    /* 初始化上传插件 */
                    $("#upload_picture_pic").uploadify({
                        "height"          : 30,
                        "swf"             : "__STATIC__/uploadify/uploadify.swf",
                        "fileObjName"     : "download",
                        "buttonText"      : "上传图片",
                        "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
                        "width"           : 120,
                        'removeTimeout'	  : 1,
                        'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
                        "onUploadSuccess" : uploadPicturepic
                    });
                    function uploadPicturepic(file, data){
                        console.log(data);
                        var data = $.parseJSON(data);
                        var src = '';
                        if(data.status){
                            $("#cover_id_pic").val(data.id);
                            src = data.url || data.path
                            $("#cover_id_path").val('__ROOT__' + src + '');
                            $("#cover_id_pic").parent().find('.upload-img-box').html(
                                    '<div class="upload-pre-item"><img src="__ROOT__' + src + '"/></div>'
                            );
                        } else {
                            updateAlert(data.info);
                            setTimeout(function(){
                                $('#top-alert').find('button').click();
                                $(that).removeClass('disabled').prop('disabled',false);
                            },1500);
                        }
                    }
                </script>
            </div>

            <div class="form-item">
                <button class="btn submit-btn" id="submit" type="submit" target-form="form-horizontal">确 定</button>
                <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
            </div>
        </form>
</block>

